package dmp.tags

import org.apache.spark.sql.Row

/**
  * author:CN.CDG
  * Date:2019/2/16
  * Time:12:50
  * 关键字标签
  **/
object Keytags extends Tags {
  override def mkTags(args: Any*): List[(String, Int)] = {
    //声明List集合用于返回结果
    var list=List[(String,Int)]()
    //解析参数
    val row = args(0).asInstanceOf[Row]
    //获取需要的字段keywords
    val keywords: String = row.getAs[String]("keywords")
    //对字段进行切分过滤,首先判断keywords是否为空
    if(!"".equals(keywords)){
      val fields = keywords.split("\\|")
     for (field <- fields){
       if(field.length>3&& field.length<=8){
         list:+=("K"+field,1)
       }
     }
    }
list
  }
}
